package com.matthew.ibatis;

import java.io.IOException;
import java.io.Reader;
import java.sql.SQLException;
import java.util.List;

import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;
import com.ibatis.common.resources.Resources;
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) throws SQLException {
		String resource="com/matthew/ibatis/sqlMapConfig.xml";
		SqlMapClient sqlMapper;
		try {
		      Reader reader = Resources.getResourceAsReader(resource);
		      sqlMapper = SqlMapClientBuilder.buildSqlMapClient(reader);
		      sqlMapper.startTransaction();
		      
		      sqlMapper.commitTransaction();
		      sqlMapper.endTransaction();
		      List list = sqlMapper.queryForList("getStatement");
		      
		      reader.close(); 
		} catch (IOException e) {
		    // Fail fast.
		   throw new RuntimeException("Something bad happened while building the SqlMapClient instance." + e, e);
		}
		
	}

}
